package cn.sxt.controller;

import cn.sxt.DataGridView;
import cn.sxt.ResultObj;
import cn.sxt.domain.Bills;
import cn.sxt.service.BillsService;
import cn.sxt.vo.BillsVo;
import org.apache.dubbo.config.annotation.Reference;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author Mxb
 * @version 1.0
 * @date 2020/5/8 10:04
 */
@RestController
@RequestMapping("/bills")
public class BillsController {
    // 远程调用暴露的服务
    @Reference
    private BillsService billsService;

    /**
     * 分页查询账单
     * @param billsVo
     * @return
     */
    @RequestMapping("/loadAllBills")
    public DataGridView findAll(BillsVo billsVo) {
        DataGridView data = billsService.findAll(billsVo);
        return data;
    }


    @RequestMapping("/add")
    public ResultObj addBills(Bills bills) {
        try {
            this.billsService.addBill(bills);
            return ResultObj.ADD_SUCCESS;
        } catch (Exception e) {
            e.printStackTrace();
            return ResultObj.ADD_ERROR;
        }
    }
}
